package com.openspring.framework.exception;

import org.apache.shiro.authz.UnauthenticatedException;
import org.apache.shiro.authz.UnauthorizedException;

public class MessageAdapter {

	public static String getMessage(Exception e) {
		String message = e.getMessage();
		if(e instanceof UnauthenticatedException) {
        	message = "用户未登陆";
        } else if(e instanceof UnauthorizedException) {
        	if(message.indexOf("role") != -1) {
        		message = "用户不属于组" + message.substring(message.indexOf('['));
        	} else if(message.indexOf("permission") != -1) {
        		message = "用户没有权限" + message.substring(message.indexOf('['));
        	}
        }
		return message;
	}
}
